package com.xspace.android.xafcommon.util;

import android.content.Context;
import android.content.Intent;
import android.text.TextUtils;
import android.view.View;

import com.xspace.android.xafcommon.R;
import com.xspace.android.xafcommon.view.dialog.ButtonClickListener;
import com.xspace.android.xafcommon.view.dialog.ConfirmDialog;

/**
 * Created by liuchen on 2016/12/13.
 */

public class Navigation {

    public static void loginConfirm(final Context mContext) {
        new ConfirmDialog.Builder(mContext).setTitleMsg(mContext.getString(R.string.register_login))
                .setContentMsg(mContext.getString(R.string.hint_login_confirm))
                .setLeftText(mContext.getString(R.string.button_ok))
                .setLeftListener(new ButtonClickListener() {
                    @Override
                    public void buttonClick(View view) {
                        Navigation.startLogin(mContext);
                    }
                }).setRightText(mContext.getString(R.string.cancel))
                .setListener().show();
    }

    /**
     * 跳转到个人中心的webview页面
     *
     * @param mContext
     * @param url
     * @param strExTitle
     */
    public static void startExtWebView(Context mContext, String url, String strExTitle) {
        Class activityClass = null;
        try {
            activityClass = Class.forName(ClassUtil.WNX_WEBVIEWACT);
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }
        Intent intent = new Intent(mContext, activityClass);// 你想去的activity(exp:Temp)
        if (!TextUtils.isEmpty(url)) {
            intent.putExtra(Constants.TITITL, strExTitle);
            intent.putExtra(Constants.WEBVIEURL, url);
        }
        mContext.startActivity(intent);
    }


    public static void startCollectActivity(Context mContext, String webpage_title, String favorite_url, String
            sender_id, String msg_org,int msg_type,String msg_deptid) {
        Class activityClass = null;
        try {
            activityClass = Class.forName(ClassUtil.MY_FAVORITE_MANAGER_ACTIVITY);
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }
        Intent intent = new Intent(mContext, activityClass);// 你想去的activity(exp:Temp)
        intent.putExtra("webpage_title", webpage_title);
        intent.putExtra("favorite_url", favorite_url);
        intent.putExtra("sender_id", sender_id);
        intent.putExtra("msg_type", msg_type);
        intent.putExtra("msg_org", msg_org);
        intent.putExtra("msg_deptid", msg_deptid);
        mContext.startActivity(intent);
    }


    public static void startCollectActivity(Context mContext, String webpage_title, String favorite_url, String
            sender_id, int msg_type) {
        Class activityClass = null;
        try {
            activityClass = Class.forName(ClassUtil.MANAGER_FAVORITOR_WEB);
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }
        Intent intent = new Intent(mContext, activityClass);// 你想去的activity(exp:Temp)
        intent.putExtra("webpage_title", webpage_title);
        intent.putExtra("favorite_url", favorite_url);
        intent.putExtra("sender_id", sender_id);
        intent.putExtra("msg_type", msg_type);
        mContext.startActivity(intent);
    }


    /**
     * 跳往登录界面
     *
     * @param mContext
     */
    public static void startLogin(Context mContext) {
        Class loginClz = null;
        try {
            loginClz = Class.forName(ClassUtil.LOGIN_CLASS);
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }
        if (loginClz != null) {
            mContext.startActivity(new Intent(mContext, loginClz));
        }
    }

    /**
     * 跳转到个人设置页面
     *
     * @param mContext
     */
    public static void startSetting(Context mContext) {
        Class loginClz = null;
        try {
            loginClz = Class.forName(ClassUtil.SETTING_CLASS);
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }
        if (loginClz != null) {
            mContext.startActivity(new Intent(mContext, loginClz));
        }
    }
}
